project(game)

file(GLOB_RECURSE _HEADER_FILES "*.h")
file(GLOB_RECURSE _SOURCE_FILES "*.cpp")
# UTF8编码
# set(CMAKE_CXX_FLAGS "/source-charset:utf-8")


find_package(sdl2 CONFIG REQUIRED)
find_package(sdl2-image CONFIG REQUIRED)
find_package(sdl2-mixer CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
    
add_executable(${PROJECT_NAME} WIN32
    ${_HEADER_FILES}
    ${_SOURCE_FILES}
)

target_link_libraries(${PROJECT_NAME} PRIVATE
    SDL2::SDL2
    SDL2::SDL2main
    SDL2::SDL2_mixer
    SDL2::SDL2_image
    nlohmann_json
)

if(WIN32)
    set_target_properties(${PROJECT_NAME} PROPERTIES
        MSVC_RUNTIME_LIBRARY "MultiThread$<$<CONFIG:Debug>:Debug>"
        COMPILE_FLAGS /Eha
    )
endif(WIN32)

add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:game>/resources
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/game/data $<TARGET_FILE_DIR:game>/data
)